<!DOCTYPE html>
<html>
<head>
<title>角色管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../include/resources.html">
<script type="text/javascript">
	var dataGrid;
	var winWidth =  480;
	var winHeight = 400;
	var addTitle = "添加";
	var addUrl =  "/modules/system/dict/dictAddPage.html";
	var editTitle = "编辑";
	var editUrl =  "/modules/system/dict/dictEditPage.html";
	$(function() {
		var editIndex = undefined;
		dataGrid = $('#dataGrid').datagrid({
			url : 'dictList.html',
			fit : true,
			fitColumns : true,
			border : false,
			pagination : true,
			idField : 'id',
			pageSize : pageSize,
			pageNums :1,
			pageList : pageList,
			sortName : 'id',
			sortOrder : 'asc',
			checkOnSelect : false,
			selectOnCheck : false,
			nowrap : false,
			singleSelect:true,
			columns : [ [ 		
				{ field: 'id', title: '编号', width: 50, fixed:true,checkbox : false},
				{ field: 'status', title: '状态', width: 50, sortable:false,formatter:function(value, row, index){
					if(value=='1'){
						return "启用";
					}else if(value=='0'){
						return "禁用";
					}
				}},
				{ field: 'sort', title: '排序', width: 50, sortable:false},
			//	{ field: 'typeId', title: '类型', width: 100, sortable:false},
				{ field: 'nid', title: '标识', width: 120, sortable:false},
				{ field: 'name', title: '名称', width: 120, sortable:false},
				{ field: 'value', title: '值', width: 220, sortable:false}, 
				{	field : 'action',
					title : '操作',
					width :50,
					fixed :true,
					formatter : function(value, row, index) {
						var str = '';
						str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',editTitle,winWidth,winHeight,editUrl);" title="'+editTitle+'">编辑</a>';
						return str;
					}
				} 
			] ],
			toolbar : '#toolbar',
			onLoadSuccess : function() {
				$('#searchForm table').show();
				parent.$.messager.progress('close');
			},
			onRowContextMenu : function(e, rowIndex, rowData) {
				e.preventDefault();
				$(this).datagrid('unselectAll').datagrid('uncheckAll');
				$(this).datagrid('selectRow', rowIndex);
				$('#menu').menu('show', {
					left : e.pageX,
					top : e.pageY
				});
			},
			onBeforeEdit:function(index,row){  
				row.editing=true;  
				$('#dataGrid').datagrid('refreshRow', index);  
		     },  
		     onAfterEdit:function(index,row){  
		    	 editIndex = undefined;
		    	 row.editing=false;
		    	 $('#dataGrid').datagrid('refreshRow', index);  
		      },  
			onDblClickRow : function(rowIndex, rowData){
				if(editIndex == undefined){
					$(this).datagrid('beginEdit', rowIndex);
					editIndex = rowIndex;
				}else{
					$(this).datagrid('endEdit', rowIndex);
				}
			}
		});
	});

function saverow(index,obj){
	$('#dataGrid').datagrid('endEdit', index);  
	    var node = $('#dataGrid').datagrid('getSelected');  
	    var json = {};  
	    json.id = node.id;  
	    json.status = node.status;  
	    json.sort = node.sort;  
	    json.typeId   = node.typeId;  
	    json.nid  = node.nid;  
	    json.name=node.name;
	    json.value=node.value;
	    $.ajax({  
	            url:'/modules/system/dict/dictEdit.html?randomTime=' + (new Date()).getTime(),  
	            type : 'post',  
	            data: json,  
	            dataType : 'json',  
	            timeout : 60000,  
	            success : function(data, textStatus, jqXHR) {     
	                if (data.result){  
	                   	$.messager.alert('提示', '保存成功！', function() {  
	                    	$('#dataGrid').datagrid('reload');  
	                    });  
	               	 }else{
	               		$.messager.alert('提示', '保存失败！');
	               	 } 
	  
	            }  
	        });  
	}	
</script>
</head>
<body style="padding:0 20px;" >
	<div class="easyui-layout" data-options="fit : true,border : false">
		 <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
        	<div class="sLeft">
	            <form id="searchForm">
	            	<input type="text"  name="searchName" class="sInput" placeholder="输入标识 /名称进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a><a href="javascript:;" class="advBtn" title="条件查询">条件查询 <i class="iconfont">&#xe638;</i></a>
	            	<a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
	            </form>
            </div>
            <div class="sRight">
				<a onclick="$.fn.dataGridOptions.addFun(-1,addTitle,winWidth,winHeight,addUrl);" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe629;</i>添加</a>					
            </div>
            <form id="showAdw">
		        <ul class="showAdw" style="display:none;">
		        	<a href="javascript:void(0);"><i class="iconfont closeWin">&#xe63a;</i></a>
		        	<li><span>标识</span><input type="text" name="nid" autocomplete="off"/></li>
		        	<li><span>名称</span><input type="text" name="name" autocomplete="off"/></li>
		        	<li>
		        		<span>状态</span>
		        		<select name="status" class="type">
		        			<option value="99">全部</option>
							<option value="1" selected="selected">启用</option>
							<option value="0">禁用</option>
						</select>
					</li>
		       		<li><span>&nbsp;</span><a href="javascript:void(0);" class="searchBtn sureBtn" onclick="$.fn.dataGridOptions.searchFun('#showAdw');">确定</a><a href="javascript:void(0);" class="searchBtn" onclick="$.fn.dataGridOptions.cleanFun('#searchForm');">重置</a></li>
		        </ul>
	        </form>
		</div>
		<div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
			<table id="dataGrid"></table>
		</div>
	</div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>
